Skip to content

Conversation

@noahemmet
Copy link

Hi! I've updated this framework to

  • Use SwiftNIO's Futures, instead of GCD.
  • Add an example app, which mirrors the default Vapor 3 project structure.
  • Fix a couple small GraphiQL bugs.

(Note that until GraphQLSwift/GraphQL#43 is merged, I'm pointing to my custom branch of GraphQLSwift.)

Thanks very much for this framework, I think it will make setting up a Swift GraphQL server much, much easier!

name: "VaporGraphQL",
targets: ["VaporGraphQL"]),
.library(
name: "StarWars",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these to a separate framework so they can be referenced from both the tests and the example app.

@@ -0,0 +1,11 @@
import Vapor

/// Creates an instance of Application. This is called from main.swift in the run target.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just Vapor's default new project files.

@@ -74,7 +74,7 @@ extension Droid : MapFallibleRepresentable {}
* This implements the following type system shorthand:
* enum Episode { NEWHOPE, EMPIRE, JEDI }
*/
let EpisodeEnum = try! GraphQLEnumType(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lowercased these instances to be more Swift-y.

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
query = try container.decode(String.self, forKey: .query)
// the decoder has trouble decoding a nil `[String: Map]`, so we'll use an optional throw.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an odd bug, the decoder was failing here. This manual try? approach fixes it but there may be a better way?

public func executeIntrospectionQuery(for req: Request) -> Future<Map> {
return self.execute(
GraphQLExecutionRequest(query: introspectionQuery, variables: [:], operationName: ""),
GraphQLExecutionRequest(query: introspectionQuery, variables: [:], operationName: nil),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was another weird bug: we check for isEmpty later, and it needs to fail in order to properly render. Passing in nil fixes it.

@nonfungibletunji
Copy link

Is there a branch o can run now

@noahemmet
Copy link
Author

You can add

.package(url: "https://github.com/noahemmet/GraphQLRouteCollection.git", .branch("futures"))

to your Package.swift's dependencies if you'd like to test. Please let me know if you find any bugs or weird behavior!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants